package com.yanduo.utils

import org.apache.spark.sql.Row

/**
  * 广告处理工具类
  *
  * @author Gerry chan
  * 2020/5/3 15:56
  * @version 1.0
  */
object RptUtils {

  def caculateReq(reqMode:Int,prcNode:Int):List[Double] = {
    // 是不是原始请求, 有效请求， 广告请求， List(原始请求，有效请求， 广告请求)
    //知识点：如果不写else ,scala默认else 返回 空的元组()
    if (reqMode == 1 && prcNode ==1) {
      List[Double](1,0,0)
    } else if(reqMode == 1 && prcNode == 2) {
      List[Double](1,1,0)
    } else if(reqMode == 1 && prcNode == 3) {
      List[Double](1,1,1)
    } else {
      List[Double](0,0,0)
    }
  }

  def caulateRtb(effTive:Int,bill:Int,bid:Int,orderId:Int,win:Int,winPrice:Double,adPayMent:Double):List[Double] = {
    //参与竞价,竞价成功， List(参与竞价， 竞价成功, 消费， 成本)

    if (effTive ==1 && bill == 1 && bid ==1 && orderId !=0) {
      List[Double](1, 0, 0, 0)
    } else if (effTive ==1 && bill == 1 && win == 1) {
      List[Double](0, 1, winPrice/1000.0, adPayMent/1000.0)
    } else List[Double](0,0,0,0)

  }

  def caculateShowClick(reqMode:Int,effTive:Int):List[Double] = {

    //广告：点击与展示
    if(reqMode ==2 && effTive ==1) {
      List[Double](1,0)
    } else if(reqMode ==3 && effTive ==1) {
      List[Double](0,1)
    } else List[Double](0,0)
  }



}
